package com.mc.search;
/**
 * 无序链表实现符号表
 * @author MC
 *
 * @param <Key>
 * @param <Value>
 */
public class SequtialSearch<Key,Value> {
	private Node first;
	private class Node{
		Key key;
		Value val;
		Node next;
		public Node(Key key,Value val,Node next){
			this.key = key;
			this.val = val;
			this.next = next;
		}
	}
	public Value get(Key key){
		for(Node node = first;node!=null;node=node.next){
			if(key==node.key)
				return node.val;
		}
		return null;
	}
	public void put(Key key,Value val){
		for(Node node = first;node!=null;node=node.next){
			if(key.equals(node.key)){
				node.val=val;
				return;
			}
		}
		first = new Node(key,val,first);
	}
}
